
package modules.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;

import modules.common.Dict;

/**
 * 生成方案Entity
 * @author ThinkGem
 * @version 2013-10-15
 */
@XmlRootElement(name="config")
public class GenConfig implements Serializable {
	
	private static final long serialVersionUID = 1L;
	private List<GenCategory> categoryList;	// 代码模板分类
	private List<Dict> javaTypeList;		// Java类型
	private List<Dict> queryTypeList;		// 查询类型
	private List<Dict> showTypeList;		// 显示类型

	public GenConfig() {
		super();
	}

	@XmlElementWrapper(name = "category")
	@XmlElement(name = "category")
	public List<GenCategory> getCategoryList() {
		if(categoryList==null){
			categoryList=new ArrayList<GenCategory>();
			GenCategory gen1=new GenCategory();
			gen1.setLabel("仅持久层（dao/entity/mapper）");
			gen1.setValue("dao");
			List<String> childTableTemplate=new ArrayList<String>();
			childTableTemplate.add("dao/dao.xml");
			childTableTemplate.add("dao/entity.xml");
			childTableTemplate.add("dao/mapper.xml");
			childTableTemplate.add("dao/service.xml");
			childTableTemplate.add("dao/controller.xml");
			gen1.setTemplate(childTableTemplate);
			categoryList.add(gen1);
		}
		return categoryList;
	}

	public void setCategoryList(List<GenCategory> categoryList) {
		this.categoryList = categoryList;
	}

	@XmlElementWrapper(name = "javaType")
	@XmlElement(name = "dict")
	public List<Dict> getJavaTypeList() {
		 
		String[] dictLable=new String[]{"String", "Long", "Integer", "Double", "Date"};
		String[] dictValue=new String[]{"String", "Long", "Integer", "Double", "java.util.Date"};
		if(javaTypeList==null){
			javaTypeList=new ArrayList<Dict>();
			for(int i=0;i<dictLable.length;i++){
				Dict dict=new Dict(); 
				dict.setLabel(dictLable[i]); 
				dict.setValue(dictValue[i]);
				javaTypeList.add(dict);
			}
		
		}
		return javaTypeList;
	}

	public void setJavaTypeList(List<Dict> javaTypeList) {
		
		this.javaTypeList = javaTypeList;
	}

	@XmlElementWrapper(name = "queryType")
	@XmlElement(name = "dict")
	public List<Dict> getQueryTypeList() {
		 
		String[] dicts=new String[]{"=", "!=", ">", ">=", "<", "<=", "Between", "Like", "Left Like", "Right Like"};
		if(queryTypeList==null){
			queryTypeList=new ArrayList<Dict>();
			for(int i=0;i<dicts.length;i++){
				Dict dict=new Dict(); dict.setLabel(dicts[i]); dict.setValue(dicts[i]);
				queryTypeList.add(dict);
			}
		
		}
			 
		return queryTypeList;
	}

	public void setQueryTypeList(List<Dict> queryTypeList) {
		this.queryTypeList = queryTypeList;
	}

	@XmlElementWrapper(name = "showType")
	@XmlElement(name = "dict")
	public List<Dict> getShowTypeList() {
		String[] dicts=new String[]{"单行文本", "多行文本", "下拉选项", "单选按钮", "复选框", "日期选择", "人员选择", "部门选择", "区域选择", "树选择控件", "文件上传选择"};
		if(queryTypeList==null){
			queryTypeList=new ArrayList<Dict>();
			for(int i=0;i<dicts.length;i++){
				Dict dict=new Dict(); dict.setLabel(dicts[i]); dict.setValue(dicts[i]);
				queryTypeList.add(dict);
			}
		
		}
		return showTypeList;
	}

	public void setShowTypeList(List<Dict> showTypeList) {
		this.showTypeList = showTypeList;
	}
	
}